package com.briup.cms.web.controller;

import com.briup.cms.aop.Logging;
import com.briup.cms.bean.BaseLog;
import com.briup.cms.service.IBaseLogService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 控制器 ，用来测试token验证
 * 所有方法需要token认证通过后访问
 *  所有的请求的url必须在/auth
 */
@RestController
@Api(tags = "日志相关接口")
@RequestMapping("/auth")
public class BaseLogController {

    @Autowired
    private IBaseLogService service;

    @Logging
    @ApiOperation("用户登陆相关日志")
    @GetMapping("/log/token")
    @ApiImplicitParams({
            //token 是保存在请求头中
            @ApiImplicitParam(name = "Authorization",value = "token值",paramType = "header")
    })
    // @ApiIgnore  : swagger文档中忽略该方法
    // @ApiIgnore : 注解参数
    public Message logTest( @ApiIgnore @RequestHeader("Authorization")  String Authorization){
        return MessageUtil.success();
    }

    @Logging
    @ApiOperation("分页查询日志信息")
    @GetMapping("/log/pageQuery")
    @ApiImplicitParams({
            //token 是保存在请求头中
            @ApiImplicitParam(name = "pageNum",value = "当前页",dataType = "int"),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",dataType = "int")
    })
    // @ApiIgnore  : swagger文档中忽略该方法
    // @ApiIgnore : 注解参数
    public Message logPage(int pageNum, int pageSize){

        System.out.println(pageNum+".....controll"+pageSize);

        return  MessageUtil.success(service.pageQuery(pageNum,pageSize));
    }


}
